﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Data.SqlTypes;
using BizUserDALEntities;
using BizUserDAL;

namespace BizUser
{

    public partial class ListingAdDetails : System.Web.UI.Page
    {
        protected void btnConfrim_OnClick(object sender, EventArgs e)
        {
                        getVariables();
            
        }

        void getVariables()
        {
            
            BizInfo oBizInfo = new BizInfo();

            oBizInfo.BizID = Convert.ToInt32(txtListingId.Text);
            oBizInfo.Title = txtTitle.Text.Trim();
            oBizInfo.BizTypeID = 1;
            oBizInfo.BizTypeName = "Test BusinessType";



            oBizInfo.CountryID =   Convert.ToInt32(Country.Text);
            oBizInfo.StateID =   Convert.ToInt32(txtState.SelectedValue);
            oBizInfo.CountyID =  1;
            oBizInfo.CityID = Convert.ToInt32(txtCity.Text.Trim());
            oBizInfo.Description = txtDescription.Text.ToString();
            oBizInfo.Address1 = txtAddress1.Text.ToString();
            oBizInfo.Zip = txtZip.Text.ToString();
            oBizInfo.Address2 = txtAddress2.Text.ToString();

            oBizInfo.CountryName = Country.SelectedItem.Text.Trim();
            oBizInfo.StateName = txtState.SelectedItem.Text.Trim();
            oBizInfo.CountyName = cmbCounty.SelectedItem.Text.Trim();
            oBizInfo.CityName = txtCity.SelectedItem.Text.Trim();
            

            
            oBizInfo.AskingPriceLow = txtAskPriceLow.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtAskPriceLow.Text.Trim()); ;
            oBizInfo.AskingPriceHigh = txtAskPriceHigh.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtAskPriceHigh.Text.Trim()); ;

            oBizInfo.GrossIncome = txtGrossIncome.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtGrossIncome.Text.Trim()); ;
            oBizInfo.CashFlow = txtCashFlow.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtCashFlow.Text.Trim()); ;
            oBizInfo.EBITDA = txtEBITDA.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtEBITDA.Text.Trim()); ;
            oBizInfo.FurnitureAndFixtures = txtFurnitureFixtures.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtFurnitureFixtures.Text.Trim()); ;
            oBizInfo.Inventory = txtInventory.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtInventory.Text.Trim()); ;

            oBizInfo.YearEstablished = Convert.ToInt32(cmbYearEstablished.SelectedValue);
            oBizInfo.NoOfEmployees = txtNumberOfEmployees.Text.Trim() == "" ? SqlInt32.Null : Convert.ToInt32(txtNumberOfEmployees.Text.Trim()); ;
            oBizInfo.ReasonForSelling = txtReasonSelling.Text.Trim();


            oBizInfo.IsRelocatable = chkIsRelocatable.Checked;
            oBizInfo.IsHomeBased = chkIsHomeBased.Checked;
            oBizInfo.IsRealEstateAvail = chkIsRealEstateAvailable.Checked;
            oBizInfo.IsAssetSale = chkIsAssetSale.Checked;
            oBizInfo.IsOwnerFinancing = chkIsOwnerFinancingAvail.Checked;
            oBizInfo.IsAbsenteeRun = chkIsAbsenteeRun.Checked;
            oBizInfo.IsRealEstateIncluded = chkIsRealEstateIncluded.Checked;
            oBizInfo.IsFSBO = chkIsFSBO.Checked;
            oBizInfo.IsBrokerCoop = chkIsBrokerCoOp.Checked;
            oBizInfo.IsTrainingAndSupportAvail = chkIsTrainingSupport.Checked;
            oBizInfo.IsFinancialAssistanceAvail = true;
            oBizInfo.IsParternshipAvail = chkIsParternshipAvailable.Checked;
            oBizInfo.IsFranchise = chkIsFranchise.Checked;

            oBizInfo.IsActive = true;// Ask Sir for Logic of it, who would determine it. User OR Admin?
            oBizInfo.IsSold = true;//  Ask Sir for Logic of it, who would determine it. User OR Admin?

            oBizInfo.IsForBuy = true;

            oBizInfo.CreatedDT = System.DateTime.Now;
            oBizInfo.UpdatedDT = System.DateTime.Now;

            Session["BizInfo"] = oBizInfo;
            Response.Redirect("ListingConfirmPayment.aspx");
            
        }



        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            getVariables();
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
            chkIsFSBO.Checked= true;

            //txtState = 1;
            //txtCountyID = 1;
            txtCity.Text = "1";
            txtGrossIncome.Text = "1";
            txtCashFlow.Text = "1";
            txtEBITDA.Text = "1";
            txtFurnitureFixtures.Text = "1";
            txtInventory.Text = "1";

            txtNumberOfEmployees.Text = "1";
            txtReasonSelling.Text = "1";

            txtDescription.Text = "1";
            txtAddress1.Text = "1";

        }
    }
}